﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Web.Mvc;

namespace Lilium.Web.Mvc
{
	internal sealed class CssReference: ScriptResourceReferenceBase
	{
		public CssReference(string libraryName, string resourceName)
			: base(libraryName, resourceName)
		{
		}

		public override void Render(AjaxHelper ajaxHelper)
		{
			if (ajaxHelper == null)
				throw new ArgumentNullException("ajaxHelper");

			var scriptReferenceBuilder = new TagBuilder("link");
			scriptReferenceBuilder.MergeAttribute("rel", "stylesheet");
			scriptReferenceBuilder.MergeAttribute("type", "text/css");
			scriptReferenceBuilder.MergeAttribute("href", GetResourceVirtualPath());
			ajaxHelper.ViewContext.HttpContext.Response.Output.WriteLine(scriptReferenceBuilder.ToString(TagRenderMode.SelfClosing));
		}
	}
}
